import request from '@/utils/request'

export interface SDConfig {
  negative_prompt: string
  width: number
  height: number
  steps: number
  cfg_scale: number
  sampler_name: string
  model: string
  seed: number
  enable_hr: boolean
  denoising_strength: number
  upscaler_scale?: number
  lora_model?: string
  lora_weight?: number
  batch_count?: number
  batch_size?: number
  hr_resize_mode?: 'scale' | 'size'
  hr_target_width?: number
  hr_target_height?: number
}

export interface SaveConfigParams extends SDConfig {
  name: string
  is_default?: boolean
}

export const saveConfig = async (params: SaveConfigParams) => {
  return await request.post('/sd_config/save_config', params)
}

export const loadConfig = async (name: string = 'default') => {
  return await request.get('/sd_config/load_config', {
    params: { name }
  })
}

export const listConfigs = async () => {
  return await request.get('/sd_config/list_configs')
}
